import { selectTableList } from '@/api/table/table-api.js'

// 材料
const state = {
  array: []
}

// 加工
const getters = {
  array2(state) {
    return state.array || []
  }
}

// 厨师
const mutations = {
  GET_DATA(state, value) {
    state.array = value
  }
}

// 迎宾
const actions = {
  // 发请求获取首页的MockJS模拟数据
  async getTableList({ commit }, params) {
    const result = await selectTableList(params)
    if (result.code === 20000) {
      commit('GET_DATA', result.data.items)
      return result
    } else {
      return Promise.reject('500')
    }
  }
}

// 分店
export default {
  state,
  getters,
  mutations,
  actions
}
